package com.iona.json.builders;

import java.util.List;

import com.iona.domain.PartDis;
import com.iona.json.JSONArray;
import com.iona.json.JSONBuilder;
import com.iona.json.JSONException;

public class PartDisBuilder extends JSONBuilder {

	private final List<PartDis> partDises;

	public PartDisBuilder(List<PartDis> findAll) {
		this.partDises = findAll;
	}

	@Override
	public Object build() throws JSONException {
		JSONArray root = new JSONArray();
		for (PartDis pd : partDises) {
			JSONArray arr = new JSONArray();
			arr.put(pd.getId());
			arr.put(pd.getName());
			root.put(arr);
		}
		return root;
	}

	@Override
	public String name() {
		return getClass().getSimpleName();
	}

}
